(function () {
    let html = document.documentElement || document.body,
        headerBar = document.querySelector('.header-bar'),
        scroll = document.querySelector('.scrollTop');

    window.onscroll = function () {
        if (html.scrollTop > 500) {
            scroll.style.opacity = 1;
            scroll.style.transition = 'all 1s';
            headerBar.style.position = 'fixed';
            headerBar.style.backgroundColor = 'black';
            headerBar.style.transition = 'all 1s';
        } else {
            scroll.style.opacity = 0;
            headerBar.style.position = 'relative';
            headerBar.style.backgroundColor = '';
            transition = 'all 1s';
        }
    }
    // 回到顶部
    scroll.onclick = function () {
        document.documentElement.scrollTop = 0;
    }

})()
